// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_activity.p_view;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import android.view.*;
import android.widget.Button;
import android.widget.PopupWindow;
import com.nnee.p_img.cls_c;
import java.util.ArrayList;
import java.util.Iterator;

// Referenced classes of package com.nnee.p_pr.p_activity.view:
//            as, h, g, bz

public class cls_f
    implements android.view.View.OnClickListener
{

    public cls_f(Context context)
    {
        c = new ArrayList();
        f = null;
        b = context;
        e = LayoutInflater.from(context);
        f = new Handler();
    }

    private int a(View view, PopupWindow popupwindow, View view1, int i, int j)
    {
        view1.measure(android.view.View.MeasureSpec.makeMeasureSpec(i, 0x80000000), android.view.View.MeasureSpec.makeMeasureSpec(popupwindow.getMaxAvailableHeight(view), 0x80000000));
        return view1.getMeasuredHeight();
    }

    public void a()
    {
        c.clear();
    }

    public void a(int i, int j)
    {
        if(j != 0);
        a(i, b.getResources().getString(j));
    }

    public void a(int i, String s)
    {
        as as1 = new cls_as(this, i, s);
        c.add(as1);
    }

    public void a(View view, int i, int j, int k)
    {
        int k1;
        int l1;
        int i2;
        Rect rect;
        int j2;
        b();
        View view1 = e.inflate(0x7f030013, null, false);
        ViewGroup viewgroup = (ViewGroup)view1.findViewById(0x7f0d0036);
        Iterator iterator = c.iterator();
        int l = c.size();
        int i1 = 0;
        while(iterator.hasNext()) 
        {
            as as1 = (as)iterator.next();
            Button button = (Button)e.inflate(0x7f030053, viewgroup, false);
            button.setText(as1.b);
            button.setTag(as1);
            int l2 = 0x7f020107;
            if(i1 == 0)
            {
                l2 = 0x7f020106;
                if(l == 1)
                    l2 = 0x7f020108;
            } else
            if(i1 == l + -1)
                l2 = 0x7f020105;
            button.setBackgroundResource(l2);
            button.setOnClickListener(this);
            viewgroup.addView(button);
            i1++;
        }
        a = new PopupWindow(view1, -2, -2);
        a.setBackgroundDrawable(new cls_bitmapDrawable());
        a.setTouchable(true);
        a.setFocusable(true);
        a.setInputMethodMode(2);
        a.setOutsideTouchable(true);
        int j1 = view.getMeasuredWidth();
        k1 = a(view, a, view1, j1, 0);
        l1 = view1.getMeasuredWidth();
        i2 = com.nnee.p_img.cls_c.a(b, 0F);
        rect = new Rect();
        view.getWindowVisibleDisplayFrame(rect);
        j2 = j - k1;
        if(i + l1 <= rect.right) goto _L2; else goto _L1
_L1:
        int k2;
        k2 = i2 + (i - l1);
        if(j2 + k1 > rect.bottom)
            j2 = j2 - k1 - k;
_L4:
        a.showAtLocation(view, 0, k2, j2);
        a.setOnDismissListener(new cls_h(this));
        return;
_L2:
        k2 = i - i2;
        if(j2 + k1 > rect.bottom)
            j2 = j2 - k1 - k;
        if(true) goto _L4; else goto _L3
_L3:
    }

    public void a(View view, int i, int j, int k, int l)
    {
        int l1;
        int i2;
        int j2;
        Rect rect;
        int k2;
        b();
        View view1 = e.inflate(0x7f030013, null, false);
        ViewGroup viewgroup = (ViewGroup)view1.findViewById(0x7f0d0036);
        Iterator iterator = c.iterator();
        int i1 = c.size();
        int j1 = 0;
        while(iterator.hasNext()) 
        {
            as as1 = (as)iterator.next();
            Button button = (Button)e.inflate(0x7f030053, viewgroup, false);
            button.setText(as1.b);
            button.setTag(as1);
            int i3 = 0x7f020107;
            if(j1 == 0)
            {
                i3 = 0x7f020106;
                if(i1 == 1)
                    i3 = 0x7f020108;
            } else
            if(j1 == i1 + -1)
                i3 = 0x7f020105;
            button.setBackgroundResource(i3);
            button.setOnClickListener(this);
            viewgroup.addView(button);
            j1++;
        }
        a = new PopupWindow(view1, -2, -2);
        a.setBackgroundDrawable(new cls_bitmapDrawable());
        a.setTouchable(true);
        a.setFocusable(true);
        a.setInputMethodMode(2);
        a.setOutsideTouchable(true);
        int k1 = view.getMeasuredWidth();
        l1 = a(view, a, view1, k1, 0);
        i2 = view1.getMeasuredWidth();
        j2 = com.nnee.p_img.cls_c.a(b, 0F);
        rect = new Rect();
        view.getWindowVisibleDisplayFrame(rect);
        k2 = j - l1 * 2;
        if(k2 < 0)
            k2 = k - l1;
        if(i + i2 <= rect.right) goto _L2; else goto _L1
_L1:
        int l2;
        l2 = j2 + (i - i2);
        if(k2 + l1 > rect.bottom)
            k2 = k2 - l1 - l;
_L4:
        a.showAtLocation(view, 0, l2, k2);
        a.setOnDismissListener(new cls_g(this));
        return;
_L2:
        l2 = i - j2;
        if(k2 + l1 > rect.bottom)
            k2 = k2 - l1 - l;
        if(true) goto _L4; else goto _L3
_L3:
    }

    public void a(cls_bz bz1)
    {
        d = bz1;
    }

    public void b()
    {
        if(a != null)
        {
            a.dismiss();
            a = null;
        }
    }

    public void onClick(View view)
    {
        b();
        if(d != null && view != null)
        {
            as as1 = (as)view.getTag();
            d.a(as1.a);
        }
    }

    private PopupWindow a;
    private Context b;
    private ArrayList c;
    private bz d;
    private LayoutInflater e;
    private Handler f;
}
